package com.louis.aop;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.aop.ThrowsAdvice;

import com.louis.mail.MailSender;

import java.lang.reflect.Method;

/**
 * 
 * <p>
 * ExceptionAdvice
 * </p>
 * 
 * @author: louisjiang
 * @version: 1.0.0,Apr 23, 20124:30:36 PM
 */
public class ExceptionAdvice implements ThrowsAdvice {

	private MailSender	mailSender;
	Logger				logger	= LogManager.getLogger(this.getClass());

	public void afterThrowing(Method method, Object[] args, Object target, Exception ex) {
		mailSender.send(ex);
		logger.error(ex);
	}

	public void setMailSender(MailSender mailSender) {
		this.mailSender = mailSender;
	}
}